<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../../plugins/mui/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/chineseHospital/index.css" />
		<script src="../../js/statistics.js"></script>
		<style>
			.header a{
				color:#fff;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav header">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">科室列表</h1>
			<!--<span></span>-->
		</header>
		<div class="body">
			<div class="father">
				<ul>
					
				</ul>
			</div>
			<div class="son">
				
			</div>
		</div>

		<script src='../../plugins/jquery/jquery-3.1.0.min.js'></script>
		<script src="../../plugins/mui/mui.min.js"></script>
		<script src="../../js/getApiToken.js"></script>
		<script src='../../plugins/template/template.js'></script>
		<script type="text/javascript" src="../../js/md5.js" ></script>
		<script src='../../plugins/fontset/fontset.js'></script>
		<script type="text/html" id="faList">
			<ul>
				{{each data as value index}}
				{{if index == 0}}<li pId="{{value.id}}" class="active">{{value.name}}</li>
				{{else}}<li pId="{{value.id}}">{{value.name}}</li>{{/if}}
				{{/each}}
			</ul>
		</script>
		<script type="text/html" id="sonList">
			{{each data as value index}}
			{{if index == 0}}
				<ul sId="{{value.id}}">
					{{each value.extra as value index}}
					<li data-id="{{value.cksbm}}">{{value.cksmc}}</li>
					{{/each}}
				</ul>
				{{else}}
				<ul sId="{{value.id}}" style="display: none;">
					{{each value.extra as value index}}
					<li data-id="{{value.cksbm}}">{{value.cksmc}}</li>
					{{/each}}
				</ul>
				{{/if}}
			{{/each}}
		</script>
		<script type="text/javascript">
			mui.init();
			
			mui.plusReady(function(){
				myAjax('home/Hospital_service/getOffice','get','',function(data){
					if(JSON.parse(data).code == 1){
						initList(JSON.parse(data).data);
					}
				})
				$(".father").delegate('li','tap',function(){
					var pid = $(this).attr('pId');
					$(this).addClass('active').siblings().removeClass('active');
					$(".son").find('ul').each(function(){
						var sid = $(this).attr('sId');
						if(pid == sid){
							$(this).show().siblings().hide();
						}
					})
				});
				//ksid : 科室ID
				mui(".son").on('tap','li',function(){
					var ksbm = $(this).attr("data-id"),
						ksmc = $(this).text();
					mui.openWindow({
						url:'section.html',
						id:'section.html',
						extras:{
							'ksbm':ksbm,
							'ksmc':ksmc
						}
					})
				});
			})
			function initList(data){
				var list = {
					data:data
				};
				var html = template('faList',list),
					html2 = template('sonList',list);
				$(".father").html(html);
				$(".son").html(html2);
			}
		</script>
	</body>
</html>